﻿<#--<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>字典目录管理</title>
 <#--   <%@include file="/WEB-INF/views/common/link.jsp" %>-->
    <#include "../common/link.ftl">
</head>
<script src="/js/plugins/messager/jquery.bootstrap.min.js"></script>
<script>
       $(function () {
           //编辑/添加按钮显示模态框
           $(".btn-input").click(function () {
                     //清空模态框
                      $("#editForm")[0].reset();
                   //有数据的话拿到数据并回显
                   var data = $(this).data('json');

                    if(data){     //编辑操作
                        $("#editForm input[name=id]").val(data.id);
                        $("#editForm input[name=title]").val(data.title);
                        $("#editForm input[name=sn]").val(data.sn);
                        $("#editForm input[name=intro]").val(data.intro);

                    }
               $("#inputModel").modal('show');
           })

           $(".btn-submit").click(function () {
               /*使用jquery-form 表单 异步提交*/
               $("#editForm").ajaxSubmit(handlerMessage)
           })
       })

</script>

<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
 <#--   <%@include file="/WEB-INF/views/common/navbar.jsp" %>-->
     <#include "../common/navbar.ftl">
    <!--菜单回显-->
  <#--  <c:set var="currentMenu" value="systemDictionary"/>-->
     <#assign currentMenu="systemDictionary"/>
    <#--<%@include file="/WEB-INF/views/common/menu.jsp" %>-->
     <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>字典目录管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/systemDictionary/list.do" method="post">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                    <a href="#" class="btn btn-success btn-input" style="margin: 10px">
                        <span class="glyphicon glyphicon-plus"></span> 添加
                    </a>
                </form>
                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
                    <table class="table table-hover table-bordered">
                        <tr>
                            <th>编号</th>
                            <th>标题</th>
                            <th>编码</th>
                            <th>简介</th>
                            <th>操作</th>
                        </tr>
                        <#list pageResult.list as systemdictionary>
                        <#--<c:forEach items="${pageResult.date}" var="systemDictionary" varStatus="vs">-->
                            <tr>
                                <td>${systemdictionary_index+1}</td>
                                <td>${systemdictionary.title}</td>
                                <td>${systemdictionary.sn}</td>
                                <td>${systemdictionary.intro}</td>

                                <td>
                                    <a href="#"  data-json='${systemdictionary.json}'
                                       class="btn btn-info btn-xs btn-input">
                                        <span class="glyphicon glyphicon-pencil"></span> 编辑
                                    </a>


                                    <a href="#" data-xxx="${systemdictionary.id}"
                                       class="btn btn-danger btn-xs btn-delete">
                                        <span class="glyphicon glyphicon-trash"></span> 删除
                                    </a>

                                </td>
                            </tr>
                        </#list>
                        <script>
                            $(".btn-delete").click(function () {
                                var $xxx = $(this).data("xxx");
                                $.messager.model = {
                                    ok: {text: '确认'},
                                    cancel: {text: '取消'}
                                }
                                //确认框
                                $.messager.confirm('警告', '数据将被删除!', function () {
                                    //点击确定后的回调函数  
                                    $.get("/systemDictionary/delete.do","id="+$xxx,function (date) {
                                        if (date.success){
                                            $.messager.popup("删除成功,两秒后自动刷新");
                                            setTimeout(function () {
                                                window.location.reload();
                                            },2000);
                                        }else {
                                            $.messager.popup("删除失败");
                                        }
                                    })
                                });
                            });
                        </script>
                    </table>
                    <!--分页-->
                    <div style="text-align: center;">
                        <ul id="pagination" class="pagination"></ul>
                        <script>
                            $("#pagination").twbsPagination({
                                totalPages: ${pageResult.pages},
                                startPage: ${pageResult.pageNum},
                                visiblePages: 5,
                                first: "首页",
                                prev: "上页",
                                next: "下页",
                                last: "尾页",
                                onPageClick: function (event, page) { //点击页码的时候会执行的方法
                                    $("#currentPage").val(page);
                                    $("#searchForm").submit();
                                }
                            });
                        </script>
                    </div>
                </div>
            </div>
        </section>
    </div>
    <#--<%@include file="/WEB-INF/views/common/footer.jsp" %>-->
    <#include "../common/footer.ftl">
</div>




<#--模态框-->
<div class="modal fade" id="inputModel" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">字典目录添加编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/systemDictionary/saveOrUpdate.do" method="post" id="editForm">
                    <input type="text"  name="id" hidden>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="name" class="col-sm-2 control-label">标题：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="title" name="title"
                                   placeholder="请输入标题名">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-2 control-label">编码：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="sn" name="sn"
                                   placeholder="请输入字典目录编码">
                        </div>
                    </div>

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-2 control-label">简介：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="intro" name="intro"
                                   placeholder="请输入字典目录简介">
                        </div>
                    </div>

                </form>


            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary btn-submit">保存</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

</body>
</html>
